<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

if(count($_POST)>0){
    while(ob_get_level()>0) ob_end_clean();

    $modules = $_POST['jfxmodule'];
    if(is_array($modules) && count($modules)>0){
        foreach($modules as $k=>$moduleKey){
            $moduleKey = $DB->escape($moduleKey);
            if($DB->countRows($CONFIG->dbprefix.'modules', "keyname = '{$moduleKey}'")>0){
                $DB->update($CONFIG->dbprefix.'modules', array('sorting'=>$k+1), "keyname = '{$moduleKey}'");
            }
        }
    }

    exit;
}



$VIEW->addJs('
$(document).ready(function(){
    var sortableStop = function(){
        var sorted = $("#jfx-list-modules").sortable("serialize");
        $.post("'.$CONFIG->adminUrl.'/modules/order/", sorted, function(){});
    }
    $("#jfx-list-modules").sortable({cursor : "pointer", stop : sortableStop });

});
');



$modules = array();
$installedModules = JFX_Module::getInstalledModules();

echo '<ul id="jfx-list-modules">';
foreach($installedModules as $k=>$v){
    if($v['keyname']===$SETTINGS->get('module-core')) continue;
    echo '<li id="jfxmodule-'.$v['keyname'].'">'.$v['title'].'</li>';
}
echo '</ul>';

















